/*
 *  Simple example of a CUnit unit test.
 *
 *  This program (crudely) demonstrates a very simple "black box"
 *  test of the standard library functions fprintf() and fread().
 *  It uses suite initialization and cleanup functions to open
 *  and close a common temporary file used by the test functions.
 *  The test functions then write to and read from the temporary
 *  file in the course of testing the library functions.
 *
 *  The 2 test functions are added to a single CUnit suite, and
 *  then run using the CUnit Basic interface.  The output of the
 *  program (on CUnit version 2.0-2) is:
 *
 *            CUnit : A Unit testing framework for C.
 *           http:cunit.sourceforge.net/
 *
 *       Suite: Suite_1
 *         Test: test of fprintf() ... passed
 *         Test: test of fread() ... passed
 *
 *       --Run Summary: Type      Total     Ran  Passed  Failed
 *                      suites        1       1     n/a       0
 *                      tests         2       2       2       0
 *                      asserts       5       5       5       0
 */

#include <stdio.h>
#include <string.h>
#include "CUnit/Basic.h"
#include "sm2.h"
#include "sm2_common.h"

/* Pointer to the file used by the tests. */
static FILE *temp_file = NULL;

/* The suite initialization function.
 * Opens the temporary file used by the tests.
 * Returns zero on success, non-zero otherwise.
 */
int init_suite1(void)
{
   if (NULL == (temp_file = fopen("temp.txt", "w+")))
   {
      return E_ERROR;
   }
   else
   {
      return 0;
   }
}

/* The suite cleanup function.
 * Closes the temporary file used by the tests.
 * Returns zero on success, non-zero otherwise.
 */
int clean_suite1(void)
{
   if (0 != fclose(temp_file))
   {
      return E_ERROR;
   }
   else
   {
      temp_file = NULL;
      return 0;
   }
}

/* Simple test of fprintf().
 * Writes test data to the temporary file and checks
 * whether the expected number of bytes were written.
 */
void test_sm2(void)
{

   int i1 = 10;
   int result;

   size_t siglen;
   uint8_t buf_1[1024] = {
       0x7C,
       0x93,
       0xAA,
       0x2C,
       0xB2,
       0x89,
       0xD3,
       0x63,
       0x94,
       0x53,
       0xCE,
       0x12,
       0x40,
       0x8F,
       0x81,
       0x29,
       0x53,
       0x33,
       0x52,
       0x8D,
       0x04,
       0x81,
       0x16,
       0x3C,
       0x76,
       0xC9,
       0x2C,
       0x2E,
       0xD5,
       0xA2,
       0x8F,
       0x48,
       0x46,
       0xE6,
       0x3B,
       0xC4,
       0x6A,
       0x17,
       0xAD,
       0x1F,
       0x89,
       0x4D,
       0x48,
       0xF7,
       0x1A,
       0xDD,
       0x66,
       0x1C,
       0x00,
       0x52,
       0x9B,
       0x96,
       0x1C,
       0x6D,
       0x86,
       0xE7,
       0xB4,
       0xB0,
       0xE6,
       0x02,
       0x46,
       0xF0,
       0xD8,
       0x14,
       0x10,
       0x07,
       0x62,
       0xAC,
       0xA1,
       0x5F,
       0x89,
       0xC7,
       0x81,
       0x26,
       0xC5,
       0x4A,
       0xC7,
       0xCB,
       0xF7,
       0x42,
       0x39,
       0x1B,
       0x65,
       0xC7,
       0x0C,
       0x9D,
       0x82,
       0x7E,
       0xB9,
       0x9C,
       0x33,
       0xAE,
       0x14,
       0xF6,
       0xD2,
       0x66,
       0x0A,
       0x80,
       0xD3,
       0xCD,
       0xB3,
       0x72,
       0xD1,
       0x42,
       0xD4,
       0xC9,
       0xFD,
       0x15,
       0x8D,
       0x77,
       0x22,
       0xF8,
       0x1C,
       0x74,
       0x41,
       0x21,
       0x3A,
       0xF3,
       0x15,
       0x9C,
       0x53,
       0x41,
       0x7D,
       0x10,
       0x69,
       0x2F,
       0xD6,
       0x04,
       0x3A,
       0x79,
       0x2C,
       0xA6,
       0x6C,
       0xBD,
       0x01,
       0x4A,
       0xE0,
       0xCE,
       0xC7,
       0x69,
       0x18,
       0xF7,
       0x74,
       0xF4,
       0xEB,
       0xA7,
       0x50,
       0xD6,
       0x8F,
       0x88,
       0xD5,
       0x41,
       0x3D,
       0x54,
       0xAE,
       0x08,
       0xC9,
       0xB1,
       0xA8,
       0xF7,
       0xD7,
       0xA6,
       0x1B,
       0x9C,
       0x59,
       0xE1,
       0x63,
       0xA1,
       0x4D,
       0x9B,
       0xF9,
       0x9F,
       0x47,
       0x20,
       0x13,
       0xC2,
       0xE6,
       0xE2,
       0xE7,
       0x6F,
       0xD8,
       0x85,
       0xB6,
       0x82,
       0xB1,
       0x35,
       0xD9,
       0x0F,
       0x2F,
       0x49,
       0x45,
       0xE9,
       0x94,
       0x89,
       0xAA,
       0x80,
       0x7F,
       0xDD,
       0x8D,
       0x24,
       0x74,
       0x5B,
       0x26,
       0x23,
       0xC2,
       0x53,
       0xBF,
       0x55,
       0xC3,
       0xDE,
       0x6A,
       0x91,
       0xA6,
       0x12,
       0xA5,
       0x97,
       0x90,
       0x90,
       0xEF,
       0x7D,
       0x80,
       0x4D,
       0x04,
       0x51,
       0xEA,
       0x5A,
       0x2B,
       0x1F,
       0x23,
       0xA3,
       0xE9,
       0x72,
       0x04,
       0x24,
       0x6F,
       0xB3,
       0xFE,
       0xFE,
       0xCB,
       0xF1,
       0xBC,
       0xEF,
       0xA4,
       0x2F,
       0x44,
       0x7D,
       0xA2,
       0x63,
       0x28,
       0x9C,
       0x84,
       0x85,
       0x6A,
       0x3E,
       0xD5,
       0xDC,
       0xBE,
       0xBB,
       0xEA,
       0x1C,
       0x9F,
       0xF9,
       0x86,
       0xC0,
       0xB4,
       0x45,
       0x08,
       0xEB,
       0x8B,
       0x04,
       0x30,
       0x9F,
       0x72,
       0x28,
       0xA8,
       0xBE,
       0x63,
       0xD3,
       0x21,
       0x2D,
       0xAA,
       0x17,
       0xC7,
       0xE8,
       0xE2,
       0xEE,
       0x76,
       0x44,
       0xC5,
       0xF3,
       0x1B,
       0x7A,
       0xCD,
       0x7A,
       0xF4,
       0xE9,
       0x8C,
       0x03,
       0xBA,
       0xB7,
       0x54,
       0xB7,
       0xCC,
       0x74,
       0x26,
       0x41,
       0xBB,
       0xA7,
       0x3E,
       0x39,
       0x7D,
       0x3B,
       0x82,
       0x8B,
       0x1C,
       0xA2,
       0x0C,
       0x74,
       0x97,
       0x27,
       0xBD,
       0x3B,
       0xDC,
       0x45,
       0xAC,
       0xEE,
       0xC1,
       0x8B,
       0x82,
       0xD4,
       0x76,
       0xAA,
       0x27,
       0xED,
       0x36,
       0xA6,
       0x12,
       0x95,
       0xAD,
       0x91,
       0x4E,
       0x0A,
       0x69,
       0xED,
       0x24,
       0x72,
       0x6F,
       0xDF,
       0x2D,
       0xF6,
       0x3A,
       0x1D,
       0x7E,
       0xA8,
       0x99,
       0x75,
       0x58,
       0xCA,
       0x9D,
       0xD9,
       0xC4,
       0x4E,
       0x15,
       0xF1,
       0xF4,
       0x0B,
       0x50,
       0x61,
       0xA2,
       0x9F,
       0xA7,
       0xE4,
       0x3B,
       0xD8,
       0x7F,
       0x47,
       0x06,
       0x9D,
       0x42,
       0x06,
       0x75,
       0xC8,
       0x4B,
       0x8C,
       0xA5,
       0x03,
       0x7C,
       0x20,
       0xBA,
       0x17,
       0x59,
       0xCC,
       0x3F,
       0x82,
       0x24,
       0x39,
       0x2B,
       0x3B,
       0xF5,
       0x86,
       0xBB,
       0x42,
       0x9A,
       0x38,
       0x83,
       0x0C,
       0xB8,
       0x19,
       0x15,
       0x50,
       0x31,
       0x2A,
       0xDB,
       0xBF,
       0x12,
       0xB1,
       0x8F,
       0x53,
       0x7D,
       0x3F,
       0xC5,
       0xF4,
       0x0E,
       0xF6,
       0xF4,
       0xD7,
       0x2A,
       0x2F,
       0x42,
       0x45,
       0xAE,
       0x3F,
       0x30,
       0xF2,
       0x65,
       0x4E,
       0xB4,
       0xC5,
       0xC6,
       0x8F,
       0x52,
       0x76,
       0x12,
       0xD9,
       0x76,
       0xD9,
       0x01,
       0xB7,
       0xBD,
       0x8A,
       0xEB,
       0x5E,
       0x8E,
       0x90,
       0x71,
       0xB9,
       0x1C,
       0x22,
       0xA3,
       0x03,
       0x95,
       0x31,
       0xA3,
       0xBC,
       0xE0,
       0xFF,
       0x1D,
       0x8D,
       0xF5,
       0x55,
       0x42,
       0xAF,
       0x9D,
       0x2D,
       0x14,
       0x75,
       0x52,
       0xE5,
       0x77,
       0x1C,
       0x38,
       0x79,
       0xE4,
       0x40,
       0x7B,
       0x0E,
       0x86,
       0xFD,
       0x30,
       0x12,
       0xBD,
       0xFA,
       0x72,
       0x5E,
       0x3B,
       0xDD,
       0x42,
       0x33,
       0xF8,
       0xEA,
       0x2A,
       0x91,
       0x4D,
       0x00,
       0x06,
       0xDC,
       0x93,
       0xD8,
       0x32,
       0xDE,
       0x11,
       0xC7,
       0x06,
       0x0E,
       0xB2,
       0xD9,
       0xF9,
       0x0C,
       0xAE,
       0x50,
       0x26,
       0x72,
       0xEF,
       0x8E,
       0xAC,
       0x2A,
       0x31,
       0xBD,
       0x3B,
       0x35,
       0x94,
       0x23,
       0x0C,
       0xAA,
       0x92,
       0xDB,
       0x6D,
       0x00,
       0x66,
       0xFF,
       0xA6,
       0xC2,
       0xA8,
       0xE2,
       0x0E,
       0xF5,
       0x6E,
       0x26,
       0x95,
       0xEE,
       0x5B,
       0xC0,
       0x17,
       0xD1,
       0x8A,
       0x4F,
       0x00,
       0xA6,
       0x8F,
       0x4C,
       0x26,
       0x0B,
       0xD6,
       0x72,
       0xE2,
       0xC5,
       0xB8,
       0xDF,
       0x4C,
       0xBB,
       0x70,
       0xC6,
       0x4A,
       0x5E,
       0x03,
       0x03,
       0x2E,
       0x50,
       0xAB,
       0x9E,
       0x99,
       0x7A,
       0x0F,
       0x1F,
       0xB0,
       0xC4,
       0x98,
       0x32,
       0x8E,
       0xA6,
       0xE7,
       0x85,
       0x6A,
       0x3F,
       0xFB,
       0xBA,
       0x5F,
       0x46,
       0x77,
       0x45,
       0xDB,
       0xE1,
       0x46,
       0x0E,
       0xA7,
       0x85,
       0xC6,
       0x1B,
       0x4B,
       0x07,
       0xFE,
       0x39,
       0xE6,
       0x61,
       0xA5,
       0xB8,
       0xF6,
       0x2C,
       0x14,
       0x5E,
       0x53,
       0x4E,
       0xFF,
       0x7D,
       0x06,
       0xCC,
       0x34,
       0x3A,
       0x6D,
       0x49,
       0xDF,
       0x0C,
       0xB2,
       0x05,
       0x7D,
       0x41,
       0x89,
       0x7C,
       0x02,
       0x4A,
       0x1F,
       0xBC,
       0xA4,
       0x85,
       0x75,
       0x53,
       0xED,
       0x49,
       0x8D,
       0xEA,
       0xCF,
       0x19,
       0x23,
       0xF0,
       0xA2,
       0xA8,
       0x15,
       0x5F,
       0xAB,
       0x0A,
       0xC5,
       0xCB,
       0x2C,
       0x78,
       0x37,
       0x17,
       0x0E,
       0x08,
       0x71,
       0xDF,
       0x48,
       0x95,
       0xC1,
       0xD0,
       0x03,
       0x2D,
       0xF7,
       0x88,
       0x1F,
       0x0C,
       0x5F,
       0x2B,
       0xD4,
       0x93,
       0x22,
       0x3F,
       0x73,
       0xBA,
       0x21,
       0x46,
       0x5F,
       0xE3,
       0x43,
       0x44,
       0xFF,
       0x70,
       0x5C,
       0x88,
       0xF5,
       0xA7,
       0xCE,
       0x9D,
       0x99,
       0x7E,
       0x21,
       0xCD,
       0x36,
       0x5D,
       0x21,
       0xBB,
       0x59,
       0xF5,
       0xB6,
       0xB8,
       0xA8,
       0x9C,
       0x49,
       0xEE,
       0x7A,
       0x8C,
       0x68,
       0xA9,
       0x3F,
       0x43,
       0xCD,
       0xC6,
       0x9C,
       0xF7,
       0xA9,
       0xBC,
       0x61,
       0xEB,
       0x32,
       0x25,
       0x64,
       0x8E,
       0x5B,
       0x4D,
       0x90,
       0xAB,
       0x13,
       0x6D,
       0x82,
       0x59,
       0xD3,
       0xB0,
       0x60,
       0x6F,
       0xC0,
       0xB4,
       0x8F,
       0x6A,
       0xCC,
       0x0F,
       0xE2,
       0x32,
       0x32,
       0x3F,
       0x21,
       0xD1,
       0x37,
       0xE8,
       0xC9,
       0x06,
       0xBE,
       0x5F,
       0xDC,
       0xC7,
       0x34,
       0x01,
       0xC2,
       0x23,
       0x4C,
       0xC4,
       0x95,
       0x5E,
       0xD9,
       0xEA,
       0x3D,
       0x19,
       0x06,
       0x60,
       0x5D,
       0xAC,
       0x78,
       0x8E,
       0xFF,
       0x8A,
       0x86,
       0x49,
       0xE8,
       0xCE,
       0x0B,
       0x88,
       0x7E,
       0x58,
       0x16,
       0x4D,
       0xB6,
       0xFF,
       0x5C,
       0x23,
       0xA9,
       0x51,
       0x77,
       0xE6,
       0x2D,
       0x50,
       0x4D,
       0x6C,
       0x15,
       0x8A,
       0x3F,
       0x39,
       0xF4,
       0x05,
       0x87,
       0xA3,
       0x17,
       0xFD,
       0xD6,
       0x3E,
       0x1D,
       0xC6,
       0x98,
       0x22,
       0x2C,
       0xA1,
       0xCF,
       0x59,
       0x01,
       0xB9,
       0xF8,
       0xBF,
       0xE2,
       0xE5,
       0xB3,
       0x73,
       0xDD,
       0x2E,
       0xBC,
       0xCC,
       0xA7,
       0xFD,
       0x8C,
       0x1D,
       0x58,
       0xB9,
       0xDF,
       0x5B,
       0x7D,
       0xBE,
       0xC2,
       0x50,
       0x09,
       0x81,
       0x44,
       0xDC,
       0xC7,
       0x59,
       0x56,
       0x3F,
       0xCA,
       0x64,
       0x67,
       0x4D,
       0x75,
       0xA6,
       0x52,
       0x4F,
       0x6F,
       0x7E,
       0x8D,
       0xAD,
       0x58,
       0x70,
       0x95,
       0x3C,
       0x6D,
       0xD1,
       0x1E,
       0x0F,
       0xD7,
       0x36,
       0x80,
       0xC8,
       0x37,
       0x90,
       0x8F,
       0xF0,
       0x7A,
       0x95,
       0xD8,
       0x91,
       0xC1,
       0x51,
       0xD8,
       0xF4,
       0xF5,
       0xC8,
       0x4C,
       0x26,
       0xEC,
       0xD6,
       0x72,
       0xD2,
       0xE5,
       0xB3,
       0x90,
       0xE3,
       0x35,
       0xCB,
       0xF2,
       0x58,
       0x55,
       0xC2,
       0x3B,
       0x15,
       0xBC,
       0x34,
       0x48,
       0xBD,
       0x91,
       0x6E,
       0xF2,
       0x15,
       0x28,
       0xA4,
       0x57,
       0xC3,
       0x79,
       0x5F,
       0x98,
       0x5A,
       0xF1,
       0x86,
       0x76,
       0x85,
       0x09,
       0x65,
       0x04,
       0xC8,
       0x7B,
       0x60,
       0xE7,
       0x57,
       0x4E,
       0x04,
       0xA6,
       0xE0,
       0xE5,
       0x46,
       0x58,
       0x8F,
       0x47,
       0x1E,
       0x3B,
       0x77,
       0xB2,
       0xD4,
       0x69,
       0x00,
       0x30,
       0x29,
       0x8D,
       0x67,
       0xFD,
       0xEA,
       0x7C,
       0x52,
       0xCE,
       0x2F,
       0xEC,
       0x54,
       0xAE,
       0xFB,
       0x4F,
       0xFB,
       0x59,
       0x81,
       0xAB,
       0x44,
       0xCC,
       0xD1,
       0x96,
       0xC2,
       0xE0,
       0x19,
       0x20,
       0x53,
       0xFC,
       0x6A,
       0x01,
       0xEB,
       0x37,
       0x2E,
       0x61,
       0xFB,
       0xA5,
       0xEA,
       0xE2,
       0x6A,
       0x4F,
       0x2E,
       0x32,
       0xD2,
       0x95,
       0xDA,
       0xDF,
       0x18,
       0x9F,
       0xED,
       0xD1,
       0x4A,
       0x1F,
       0x03,
       0xC5,
       0x68,
       0xB3,
       0xD1,
       0x2C,
       0x09,
       0xE9,
       0x27,

   };

   uint8_t Private_Key_Test1[32] = {
       0xBF, 0x72, 0x24, 0x72, 0x6B, 0xCF, 0x10, 0x2D, 0xF8, 0x55, 0x91, 0x52, 0x46, 0xB1, 0x13, 0x65, 0x5B, 0x39, 0x76, 0xF4, 0xD2, 0xA4, 0xD8, 0x49, 0x7A, 0x14, 0xAD, 0xD5, 0x0D, 0x82, 0xF2, 0x9C};
   uint8_t Publickey_Test1[64] = {
       0x50, 0xE2, 0x78, 0xAB, 0xBA, 0xB4, 0x5C, 0xA2, 0xE8, 0x13, 0x41, 0x99, 0xE0, 0xED, 0xE0, 0xCA, 0xA6, 0x94, 0xD3, 0xDE, 0x26, 0xC9, 0xFC, 0xEF, 0xFC, 0xDF, 0xEE, 0xDC, 0x85, 0x92, 0xCC, 0x9D,
       0x4E, 0x6E, 0xDE, 0x36, 0x2A, 0x2C, 0x62, 0x47, 0xA1, 0x56, 0x33, 0x63, 0x84, 0xDC, 0x9C, 0x09, 0xE3, 0x6B, 0x14, 0xB5, 0x63, 0x9B, 0xEB, 0xDD, 0x1B, 0x99, 0xC9, 0x2A, 0x4E, 0x46, 0x44, 0xCD};

   uint8_t Sig_Result[peace_sm2_MAX_SIGNATURE_SIZE];
   uint8_t Sig_R[32];
   uint8_t Sig_S[32];

   result = peace_sm2_sign(buf_1, sizeof(buf_1), Private_Key_Test1, Publickey_Test1, &Sig_Result[0], Sig_R, Sig_S, &siglen);
   for (int i = 0; i < siglen; i++)
   {
      printf("%02x ", Sig_Result[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_R[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_S[i]);
   }
   printf("\n");
   CU_ASSERT_EQUAL(result, E_OK);
   result = peace_sm2_verify(buf_1, sizeof(buf_1), Private_Key_Test1, Publickey_Test1, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_OK);
   Sig_Result[2] += 1;
   Sig_Result[5] += 1;
   result = peace_sm2_verify(buf_1, sizeof(buf_1), Private_Key_Test1, Publickey_Test1, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_NOT_OK);
   uint8_t buf_2[1024] = {

       0xBF,
       0xF0,
       0xEA,
       0xBB,
       0xB6,
       0xFD,
       0xF1,
       0xAB,
       0xBC,
       0x59,
       0x1E,
       0x87,
       0xFD,
       0x4E,
       0x32,
       0xC6,
       0x14,
       0x9A,
       0x84,
       0xF4,
       0x24,
       0x1F,
       0xFA,
       0xF3,
       0xA7,
       0x2A,
       0xEB,
       0x71,
       0x9A,
       0x84,
       0xCF,
       0xE8,
       0x59,
       0xBB,
       0x1C,
       0x3E,
       0x0E,
       0x76,
       0x53,
       0x73,
       0x4D,
       0xAD,
       0xAA,
       0x7F,
       0x55,
       0xD7,
       0x97,
       0xAB,
       0xB0,
       0x1A,
       0x87,
       0xC8,
       0x86,
       0x84,
       0x2E,
       0x12,
       0xAD,
       0x7F,
       0x57,
       0x7C,
       0xB3,
       0xAC,
       0x82,
       0x71,
       0x44,
       0xBE,
       0xD6,
       0x74,
       0x35,
       0xAB,
       0x75,
       0xCB,
       0xF8,
       0xAE,
       0x7D,
       0x5B,
       0x05,
       0xD7,
       0xED,
       0x39,
       0xA9,
       0x32,
       0xD5,
       0xBE,
       0x08,
       0xA4,
       0x2A,
       0xEB,
       0xA9,
       0x0B,
       0xE4,
       0x3A,
       0x9A,
       0x87,
       0x89,
       0x06,
       0x07,
       0x30,
       0x11,
       0x03,
       0xD3,
       0xC2,
       0x3C,
       0x79,
       0x04,
       0x2E,
       0x9E,
       0x0E,
       0x7C,
       0xC9,
       0x45,
       0x03,
       0x8C,
       0xFA,
       0xF9,
       0xD9,
       0xF9,
       0x7A,
       0x0F,
       0xF9,
       0x07,
       0x05,
       0xA2,
       0x36,
       0xB1,
       0x0A,
       0xE5,
       0x2E,
       0xEE,
       0xBC,
       0xAA,
       0x07,
       0x18,
       0xAF,
       0xDB,
       0xAF,
       0xB1,
       0x9E,
       0x50,
       0x02,
       0x25,
       0x07,
       0x1C,
       0x92,
       0x0F,
       0x9F,
       0x5B,
       0x79,
       0xAF,
       0x79,
       0x61,
       0xB0,
       0x3F,
       0x4E,
       0x02,
       0xB1,
       0xC6,
       0xB7,
       0x02,
       0x10,
       0x29,
       0xFE,
       0xC3,
       0x5F,
       0x8A,
       0x71,
       0xF6,
       0xB0,
       0xD7,
       0x9A,
       0x50,
       0x47,
       0xFF,
       0xF9,
       0xEC,
       0xF3,
       0x1F,
       0x5F,
       0xAB,
       0x46,
       0x9D,
       0xD9,
       0xF1,
       0x19,
       0x92,
       0xFB,
       0x7C,
       0x1B,
       0xF7,
       0x03,
       0xC2,
       0xB4,
       0x8C,
       0x00,
       0x4D,
       0xF9,
       0xDF,
       0x91,
       0x47,
       0x70,
       0x2A,
       0x0A,
       0x67,
       0xC4,
       0x57,
       0xB5,
       0x9E,
       0xBD,
       0xA8,
       0xE2,
       0x97,
       0x16,
       0xE9,
       0x0A,
       0x80,
       0x75,
       0xA4,
       0x7B,
       0x8D,
       0x3C,
       0xC3,
       0x23,
       0xA5,
       0xEB,
       0xFB,
       0x8F,
       0x3A,
       0x43,
       0x05,
       0x74,
       0xF9,
       0xE1,
       0x93,
       0x5F,
       0x20,
       0xB1,
       0xDE,
       0x07,
       0x40,
       0x18,
       0xD0,
       0x81,
       0xEB,
       0x6D,
       0x2B,
       0xBE,
       0x30,
       0x9E,
       0x21,
       0x5C,
       0x4D,
       0x5C,
       0xDF,
       0x78,
       0xC5,
       0x31,
       0xC3,
       0x04,
       0xE0,
       0xFA,
       0xC7,
       0x60,
       0x01,
       0x5B,
       0x7D,
       0xA5,
       0x87,
       0x3A,
       0xBB,
       0x6C,
       0xE7,
       0xFA,
       0x26,
       0x00,
       0x1E,
       0xF3,
       0x90,
       0x53,
       0xAE,
       0x0F,
       0x01,
       0x88,
       0x96,
       0x99,
       0xC4,
       0x7C,
       0x66,
       0xA3,
       0xC8,
       0xD5,
       0x28,
       0xC1,
       0x85,
       0x2C,
       0x4F,
       0x4D,
       0x53,
       0x60,
       0x12,
       0xAA,
       0xA2,
       0x29,
       0xE2,
       0xA3,
       0xBE,
       0xE9,
       0xFE,
       0x0A,
       0xCE,
       0x74,
       0x69,
       0x24,
       0x72,
       0xF2,
       0x1C,
       0x65,
       0x37,
       0x69,
       0x01,
       0x3B,
       0x85,
       0x11,
       0xB6,
       0xD7,
       0xA1,
       0x6B,
       0xCB,
       0x70,
       0xFF,
       0x3F,
       0xFD,
       0x90,
       0x15,
       0x82,
       0xD8,
       0x67,
       0xEF,
       0x0D,
       0xEB,
       0x03,
       0x83,
       0x49,
       0xB1,
       0x51,
       0x3C,
       0x20,
       0x4B,
       0xAD,
       0xE7,
       0x33,
       0x5E,
       0x69,
       0x7A,
       0xCB,
       0x63,
       0x1B,
       0x29,
       0x09,
       0xFD,
       0x00,
       0x13,
       0xDC,
       0x5E,
       0x65,
       0x71,
       0x31,
       0x3B,
       0x39,
       0x9F,
       0x5E,
       0xEA,
       0xAA,
       0x21,
       0x60,
       0x93,
       0x56,
       0xE9,
       0x65,
       0x2E,
       0x3D,
       0x46,
       0xBA,
       0x4D,
       0xB8,
       0x93,
       0xA4,
       0xB4,
       0xFD,
       0x38,
       0x49,
       0x79,
       0x93,
       0x60,
       0x70,
       0x6E,
       0xE0,
       0xC0,
       0x86,
       0xEB,
       0xF7,
       0x7C,
       0xEC,
       0x8F,
       0xAE,
       0x8C,
       0xAE,
       0x2F,
       0xFB,
       0x59,
       0xE7,
       0x3B,
       0x48,
       0x81,
       0xB1,
       0xE3,
       0xF6,
       0x01,
       0xF1,
       0x81,
       0x25,
       0x6A,
       0x3C,
       0x9A,
       0x8E,
       0xCB,
       0x4D,
       0x51,
       0x98,
       0x0C,
       0xAE,
       0x10,
       0xAB,
       0x31,
       0x9E,
       0x03,
       0x24,
       0x06,
       0x96,
       0x69,
       0x9B,
       0xC4,
       0xE3,
       0xD8,
       0x26,
       0xAC,
       0xBD,
       0x76,
       0x74,
       0x13,
       0x69,
       0x29,
       0x9D,
       0xA0,
       0x4B,
       0x8C,
       0x20,
       0xA5,
       0x75,
       0x26,
       0xC8,
       0x73,
       0x99,
       0xC0,
       0xF1,
       0xC8,
       0xC5,
       0xF3,
       0x53,
       0x24,
       0xB2,
       0xBF,
       0x9A,
       0xCA,
       0x9E,
       0xC3,
       0xD9,
       0xED,
       0x67,
       0x3E,
       0xDD,
       0x6B,
       0xEC,
       0x2D,
       0x8B,
       0xC3,
       0xCE,
       0x42,
       0x1E,
       0x83,
       0x6F,
       0xA4,
       0xFF,
       0x70,
       0x7F,
       0xDC,
       0x2E,
       0xD5,
       0xAE,
       0x58,
       0xC7,
       0x48,
       0x26,
       0x21,
       0x93,
       0x26,
       0xC2,
       0x58,
       0x98,
       0x60,
       0xFB,
       0x5E,
       0x54,
       0x2C,
       0x8F,
       0xA5,
       0xF3,
       0xC8,
       0x27,
       0xFD,
       0x28,
       0xA2,
       0x50,
       0x3B,
       0xCD,
       0xE0,
       0xE1,
       0xE8,
       0x9D,
       0x70,
       0x2C,
       0xA9,
       0x9E,
       0xE9,
       0x79,
       0xEE,
       0x8D,
       0x0E,
       0xB3,
       0xEC,
       0x8A,
       0xCB,
       0xC3,
       0xCA,
       0xB5,
       0x29,
       0x37,
       0xE5,
       0xA8,
       0x2C,
       0x3A,
       0xB1,
       0xB9,
       0x4B,
       0xAB,
       0xC7,
       0x10,
       0x25,
       0x9C,
       0x1A,
       0x51,
       0xFE,
       0xF6,
       0xFD,
       0x8F,
       0x38,
       0x12,
       0x53,
       0x31,
       0x93,
       0x0F,
       0x96,
       0x7E,
       0x09,
       0x3F,
       0x52,
       0x20,
       0x5A,
       0x5D,
       0x7C,
       0x93,
       0x04,
       0xA3,
       0x31,
       0xA2,
       0xC3,
       0x79,
       0x82,
       0xC7,
       0x66,
       0x1A,
       0x8D,
       0x6E,
       0xB9,
       0x7F,
       0x0E,
       0xC1,
       0x23,
       0x24,
       0x50,
       0x71,
       0x00,
       0xB2,
       0xB6,
       0x7B,
       0x64,
       0x40,
       0x8D,
       0x5C,
       0xF3,
       0x27,
       0x8E,
       0x4A,
       0xE2,
       0x31,
       0x53,
       0x41,
       0x3F,
       0xB2,
       0xC8,
       0x2F,
       0xA0,
       0x1D,
       0x14,
       0xDD,
       0x3E,
       0xC4,
       0x5A,
       0x2D,
       0x9A,
       0x9E,
       0xD8,
       0x66,
       0xDB,
       0xBE,
       0x37,
       0x24,
       0x76,
       0xA1,
       0x43,
       0xCC,
       0xC7,
       0x54,
       0xAB,
       0x6F,
       0x04,
       0x6A,
       0xDE,
       0x76,
       0x65,
       0x6E,
       0x39,
       0x5E,
       0x24,
       0xFA,
       0x96,
       0x43,
       0x1C,
       0x5B,
       0xD1,
       0x0D,
       0x7D,
       0x44,
       0xD2,
       0x36,
       0xF5,
       0x11,
       0x1A,
       0xB3,
       0xE0,
       0x0F,
       0x49,
       0x6D,
       0xD0,
       0x45,
       0x2D,
       0x8E,
       0xF8,
       0xC7,
       0xC2,
       0x74,
       0x0C,
       0x93,
       0x54,
       0x21,
       0x5D,
       0xF2,
       0x43,
       0x86,
       0x18,
       0x98,
       0x86,
       0x9C,
       0xE7,
       0xCC,
       0x3B,
       0x84,
       0x5C,
       0xB6,
       0xCA,
       0x92,
       0xE4,
       0x5B,
       0x94,
       0x48,
       0xA1,
       0x2A,
       0x38,
       0xC3,
       0x3D,
       0x3F,
       0x30,
       0x87,
       0xFA,
       0x24,
       0x0A,
       0x5A,
       0x37,
       0x34,
       0xFE,
       0xF7,
       0x83,
       0xA1,
       0x2F,
       0x4B,
       0x42,
       0xD0,
       0xCA,
       0x87,
       0x81,
       0x33,
       0x8E,
       0x61,
       0xF0,
       0xF9,
       0x6D,
       0x00,
       0xC7,
       0x80,
       0x1E,
       0x3D,
       0xD9,
       0x72,
       0xCC,
       0xFB,
       0xED,
       0x76,
       0xB9,
       0xE0,
       0x6F,
       0xE1,
       0xAF,
       0x60,
       0xFE,
       0x19,
       0x1C,
       0xE9,
       0x4B,
       0xA6,
       0x63,
       0x8C,
       0xC8,
       0x2F,
       0x99,
       0x3F,
       0x85,
       0x0E,
       0x40,
       0xF5,
       0x83,
       0xCD,
       0xA1,
       0xAF,
       0xDF,
       0x27,
       0xA4,
       0xF2,
       0xEC,
       0x2A,
       0x4F,
       0x51,
       0x84,
       0x37,
       0xEC,
       0x66,
       0x3A,
       0x8E,
       0xD1,
       0xD7,
       0x76,
       0x58,
       0x5B,
       0xD6,
       0x91,
       0xB1,
       0x87,
       0x24,
       0xDF,
       0x7E,
       0xCB,
       0x35,
       0x10,
       0xC7,
       0x48,
       0xB8,
       0xD6,
       0x22,
       0x66,
       0x41,
       0x12,
       0x4F,
       0x14,
       0xB5,
       0x90,
       0xB9,
       0xD9,
       0x53,
       0x08,
       0x00,
       0x9F,
       0x6E,
       0xCE,
       0x34,
       0xF3,
       0xDC,
       0x8C,
       0x82,
       0x6D,
       0xFA,
       0x20,
       0x5A,
       0x49,
       0xBE,
       0x27,
       0xB5,
       0x03,
       0xE0,
       0x61,
       0x14,
       0x4C,
       0x81,
       0x01,
       0x11,
       0xC5,
       0x63,
       0x03,
       0x1D,
       0x2A,
       0x9C,
       0x48,
       0x93,
       0xBD,
       0x82,
       0xFF,
       0xFE,
       0xFA,
       0x5E,
       0xB4,
       0x9C,
       0x7E,
       0xFA,
       0x13,
       0x6E,
       0x4B,
       0x42,
       0x04,
       0xD3,
       0x8C,
       0x16,
       0x38,
       0x1D,
       0xDC,
       0xF2,
       0x9A,
       0x3A,
       0xC5,
       0x91,
       0xA3,
       0x99,
       0x8B,
       0x64,
       0x48,
       0x88,
       0x7B,
       0xD3,
       0x19,
       0x4C,
       0x06,
       0xAE,
       0xC9,
       0x2D,
       0x36,
       0x60,
       0x8C,
       0x23,
       0xE4,
       0x1E,
       0x0E,
       0xEC,
       0x53,
       0x7E,
       0xE1,
       0xFD,
       0x83,
       0x70,
       0x26,
       0x14,
       0xFC,
       0x5F,
       0xFD,
       0xCD,
       0x15,
       0xA7,
       0x8F,
       0xF6,
       0x17,
       0xF0,
       0xA9,
       0x5C,
       0x54,
       0x18,
       0x1C,
       0x4F,
       0xA4,
       0xB9,
       0x09,
       0x78,
       0x6E,
       0x33,
       0xC0,
       0x11,
       0xF7,
       0xFD,
       0x2B,
       0x09,
       0x42,
       0x44,
       0x27,
       0xBF,
       0x4B,
       0x01,
       0x66,
       0x43,
       0xAF,
       0x87,
       0xCB,
       0x69,
       0x79,
       0x2C,
       0xDE,
       0xA8,
       0xA0,
       0x4B,
       0xF7,
       0xD0,
       0xD5,
       0xA7,
       0xE7,
       0x04,
       0x2C,
       0x8C,
       0x06,
       0x1A,
       0xB8,
       0x26,
       0xE4,
       0xB8,
       0x5F,
       0x65,
       0xC7,
       0x3C,
       0x6C,
       0xF6,
       0x67,
       0xCD,
       0x52,
       0x09,
       0x79,
       0x05,
       0x59,
       0x6F,
       0x2F,
       0x95,
       0x58,
       0xF1,
       0xD6,
       0x35,
       0x3C,
       0x77,
       0xAC,
       0x3C,
       0xBC,
       0x42,
       0x10,
       0xA5,
       0x6F,
       0xEC,
       0x70,
       0xBA,
       0x5D,
       0x5F,
       0x56,
       0xEE,
       0x7D,
       0xDA,
       0xC3,
       0xBC,
       0xF9,
       0x6D,
       0xB4,
       0xBB,
       0x59,
       0x20,
       0xA7,
       0x86,
       0x94,
       0xF7,
       0x3A,
       0x7E,
       0x05,
       0x2D,
       0x00,
       0xE3,
       0x36,
       0xB4,

   };

   uint8_t Private_Key_Test2[32] = {
       0x2E, 0x27, 0x66, 0x40, 0x5F, 0x26, 0x4E, 0x74,
       0xFE, 0x70, 0x45, 0x64, 0x13, 0x0C, 0x0E, 0x45,
       0x5C, 0xF1, 0x2B, 0x42, 0x2B, 0x1D, 0xC7, 0x74,
       0xF5, 0x7D, 0x7A, 0xD7, 0x5E, 0x1F, 0x4E, 0x86};
   uint8_t Publickey_Test2[64] = {
       0x15, 0x2E, 0x16, 0x68, 0x54, 0x6B, 0x40, 0xA9, 0x21, 0xC9, 0x4D, 0xCA, 0x04, 0xF3, 0xA5, 0x56,
       0xBF, 0xFE, 0x81, 0x20, 0xA4, 0xCD, 0x5A, 0x1D, 0x91, 0x4C, 0x83, 0xDA, 0xB3, 0x72, 0x42, 0xD1,
       0x60, 0xC9, 0xDA, 0xB3, 0x79, 0x72, 0x41, 0xD1, 0xE2, 0x9E, 0x28, 0x0D, 0x57, 0x79, 0x71, 0xFB,
       0xB0, 0xFC, 0xF4, 0x24, 0xC8, 0xB3, 0x75, 0x34, 0xDC, 0x35, 0x51, 0xCA, 0x68, 0xEF, 0x29, 0x57};
   result = peace_sm2_sign(buf_2, sizeof(buf_2), Private_Key_Test2, Publickey_Test2, &Sig_Result[0], Sig_R, Sig_S, &siglen);
   for (int i = 0; i < siglen; i++)
   {
      printf("%02x ", Sig_Result[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_R[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_S[i]);
   }
   printf("\n");
   CU_ASSERT_EQUAL(result, E_OK);
   result = peace_sm2_verify(buf_2, sizeof(buf_2), Private_Key_Test2, Publickey_Test2, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_OK);
   Sig_Result[2] += 1;
   Sig_Result[5] += 1;
   result = peace_sm2_verify(buf_2, sizeof(buf_2), Private_Key_Test2, Publickey_Test2, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_NOT_OK);
   uint8_t buf_3[1024] = {

       0xDA,
       0xD8,
       0x9E,
       0x5B,
       0xD3,
       0xFB,
       0x3E,
       0x38,
       0xE7,
       0xA6,
       0xD7,
       0x72,
       0x88,
       0x1D,
       0xB6,
       0x5F,
       0x21,
       0x0C,
       0xBA,
       0xE2,
       0x24,
       0xA2,
       0x3D,
       0x28,
       0x64,
       0x1E,
       0xC2,
       0x64,
       0x68,
       0xF2,
       0x19,
       0x5F,
       0x67,
       0x14,
       0xD6,
       0x9D,
       0x95,
       0x4E,
       0x0C,
       0x23,
       0x1B,
       0x49,
       0x39,
       0x3D,
       0xEC,
       0x73,
       0x06,
       0xC8,
       0x71,
       0xC7,
       0x20,
       0xC4,
       0x7D,
       0xAD,
       0xA7,
       0xA3,
       0x6A,
       0xCD,
       0x4E,
       0xF5,
       0xA7,
       0xED,
       0x67,
       0x64,
       0xF1,
       0x6D,
       0x11,
       0xF5,
       0x8B,
       0x77,
       0x8D,
       0x5C,
       0xA8,
       0x13,
       0x4F,
       0x23,
       0xEF,
       0x38,
       0x7A,
       0xF0,
       0x58,
       0x57,
       0x66,
       0x07,
       0x9F,
       0x76,
       0x4A,
       0xCF,
       0x8A,
       0x16,
       0x3A,
       0xF3,
       0xA5,
       0x9B,
       0xDA,
       0xE9,
       0x66,
       0x78,
       0x19,
       0xBF,
       0x5F,
       0x84,
       0xFC,
       0x7A,
       0x83,
       0x2B,
       0x3C,
       0x9E,
       0x2F,
       0xBC,
       0x32,
       0xB8,
       0x9D,
       0x1D,
       0x97,
       0x5B,
       0x89,
       0x4F,
       0x82,
       0xA7,
       0xC3,
       0x7D,
       0xA8,
       0xC6,
       0xBB,
       0x17,
       0x5C,
       0x2D,
       0xD4,
       0xC4,
       0x0B,
       0x78,
       0xE0,
       0x24,
       0x8E,
       0xDF,
       0x8F,
       0xA9,
       0xAF,
       0xE9,
       0x26,
       0xC2,
       0x4D,
       0x0D,
       0x91,
       0x70,
       0xC8,
       0x88,
       0x18,
       0xDE,
       0xBA,
       0xA4,
       0xF9,
       0x04,
       0xD5,
       0xDF,
       0xCE,
       0x69,
       0xD5,
       0x95,
       0xF8,
       0xB6,
       0x7E,
       0x08,
       0x98,
       0x1F,
       0x13,
       0x12,
       0x8C,
       0x66,
       0x99,
       0xC9,
       0xE4,
       0x50,
       0x1F,
       0x9C,
       0xF5,
       0x35,
       0xCE,
       0x94,
       0x79,
       0xA0,
       0x03,
       0x2B,
       0xC8,
       0xC3,
       0xCF,
       0x5A,
       0x18,
       0x16,
       0xE7,
       0x2C,
       0x37,
       0x56,
       0x19,
       0x66,
       0x22,
       0x28,
       0x4B,
       0x51,
       0x13,
       0x73,
       0xAF,
       0x7E,
       0xDC,
       0x28,
       0x3D,
       0x8F,
       0x1D,
       0x50,
       0x48,
       0x2D,
       0xC4,
       0xF2,
       0x4B,
       0xC8,
       0xFE,
       0x0B,
       0x96,
       0x42,
       0x3F,
       0xDC,
       0x13,
       0x84,
       0xAD,
       0x7A,
       0xA9,
       0x30,
       0xC5,
       0xA0,
       0x78,
       0x27,
       0xF8,
       0x7F,
       0x77,
       0x34,
       0x9F,
       0x6C,
       0x34,
       0x77,
       0xDA,
       0xD0,
       0x5D,
       0xDE,
       0xE2,
       0x54,
       0xDF,
       0xC7,
       0xA0,
       0x74,
       0xB4,
       0xA2,
       0xD0,
       0x94,
       0x96,
       0x78,
       0xCA,
       0xA5,
       0xCE,
       0x40,
       0x3B,
       0x1E,
       0xDE,
       0xED,
       0x07,
       0x0C,
       0xC2,
       0x9E,
       0x88,
       0x6B,
       0xB3,
       0xD0,
       0xB5,
       0xDD,
       0x8F,
       0x20,
       0x1F,
       0x2A,
       0xDD,
       0xFD,
       0xA8,
       0x8B,
       0x09,
       0x6E,
       0xAD,
       0x06,
       0x5B,
       0x6F,
       0x8C,
       0x8C,
       0x54,
       0xDC,
       0x17,
       0x93,
       0x4F,
       0xA3,
       0xA6,
       0x63,
       0x06,
       0xFE,
       0x0A,
       0xC1,
       0x47,
       0x51,
       0x7D,
       0xDD,
       0x6E,
       0x2B,
       0xD8,
       0x32,
       0x71,
       0x7B,
       0x6B,
       0xD7,
       0xF0,
       0x98,
       0x5D,
       0x64,
       0xBD,
       0x04,
       0x98,
       0xB3,
       0xC3,
       0xF8,
       0x57,
       0xF9,
       0x83,
       0x23,
       0xE0,
       0xB9,
       0x9E,
       0x9A,
       0x14,
       0x6C,
       0x0E,
       0x95,
       0x16,
       0x20,
       0x83,
       0xCF,
       0xAB,
       0x39,
       0x99,
       0x94,
       0x58,
       0x66,
       0x58,
       0x05,
       0x73,
       0x78,
       0x6A,
       0x3C,
       0xE4,
       0x01,
       0xF2,
       0x95,
       0xC0,
       0xA6,
       0xB1,
       0x21,
       0x83,
       0x74,
       0xC5,
       0x34,
       0xAA,
       0x48,
       0x4B,
       0x14,
       0x84,
       0x74,
       0x5E,
       0x01,
       0x62,
       0x29,
       0xA1,
       0xD8,
       0xBC,
       0x6B,
       0x46,
       0xF1,
       0xB6,
       0xB3,
       0xE3,
       0xBE,
       0x36,
       0xAA,
       0x15,
       0x1F,
       0x78,
       0x53,
       0x97,
       0x3C,
       0x28,
       0x57,
       0xD2,
       0xD1,
       0x8D,
       0x40,
       0x12,
       0x49,
       0x05,
       0xF2,
       0xB1,
       0x6D,
       0x92,
       0x74,
       0x2C,
       0x56,
       0xD6,
       0xFC,
       0x28,
       0x82,
       0x09,
       0xA0,
       0x60,
       0xF5,
       0x3D,
       0x18,
       0x3A,
       0x5F,
       0x4D,
       0x82,
       0x88,
       0x35,
       0x61,
       0xAF,
       0xE7,
       0xE3,
       0x4C,
       0xAD,
       0x33,
       0xF4,
       0xDE,
       0xD6,
       0x56,
       0x64,
       0xBA,
       0x1D,
       0xCE,
       0xAD,
       0x61,
       0xD9,
       0xA1,
       0x1F,
       0xDA,
       0x4A,
       0x37,
       0xBC,
       0x32,
       0x52,
       0x9E,
       0x6C,
       0x5F,
       0x64,
       0x35,
       0xAF,
       0x82,
       0x5A,
       0xEC,
       0x4F,
       0xF3,
       0xA5,
       0x26,
       0x59,
       0xF3,
       0xFF,
       0x3B,
       0xB1,
       0x77,
       0x85,
       0x67,
       0x15,
       0x98,
       0xD2,
       0x2E,
       0xCB,
       0x09,
       0xEC,
       0x3D,
       0x6A,
       0xA7,
       0x79,
       0xF8,
       0x60,
       0xA0,
       0x8D,
       0x5B,
       0xF9,
       0x66,
       0x53,
       0x56,
       0xF3,
       0x6F,
       0xEF,
       0xC9,
       0xDE,
       0xC9,
       0x5A,
       0x85,
       0x8D,
       0x1D,
       0x95,
       0x71,
       0xD5,
       0xE9,
       0x08,
       0xDA,
       0xEB,
       0x1D,
       0x7A,
       0x93,
       0xAC,
       0x58,
       0x80,
       0xA9,
       0xE1,
       0x32,
       0x88,
       0x11,
       0xF9,
       0x18,
       0x90,
       0x3B,
       0x61,
       0xBC,
       0x87,
       0xCE,
       0xF5,
       0x3C,
       0x41,
       0x32,
       0x56,
       0xED,
       0x87,
       0xAD,
       0x98,
       0xCA,
       0x80,
       0x39,
       0xDB,
       0x5A,
       0x68,
       0xB3,
       0xBA,
       0x79,
       0x43,
       0x05,
       0xDD,
       0x80,
       0xAE,
       0x24,
       0xE6,
       0x0A,
       0x6A,
       0x4F,
       0xE2,
       0xA5,
       0x67,
       0x6E,
       0x94,
       0x30,
       0xF2,
       0x5C,
       0x89,
       0x85,
       0xD0,
       0xFB,
       0x07,
       0x27,
       0x31,
       0x44,
       0xCB,
       0x64,
       0x1F,
       0xCC,
       0x4E,
       0x61,
       0x17,
       0x49,
       0xA7,
       0xED,
       0xD2,
       0x61,
       0x22,
       0x1A,
       0xB1,
       0x08,
       0x57,
       0x3F,
       0x05,
       0x7F,
       0x84,
       0xAD,
       0x20,
       0x37,
       0x72,
       0x57,
       0x07,
       0xE7,
       0x3B,
       0xA2,
       0x7F,
       0x06,
       0xD5,
       0x98,
       0x4B,
       0xE2,
       0x09,
       0xC4,
       0x83,
       0x3F,
       0xB6,
       0xBC,
       0x5F,
       0x1F,
       0x80,
       0xE2,
       0x40,
       0xA8,
       0x4E,
       0x5C,
       0x96,
       0xDB,
       0x1B,
       0x9E,
       0x6E,
       0xAD,
       0x47,
       0x7D,
       0xD9,
       0x27,
       0x91,
       0xE3,
       0xCC,
       0x18,
       0xBB,
       0xF2,
       0x50,
       0x51,
       0x76,
       0x65,
       0xEA,
       0x75,
       0x23,
       0xB9,
       0x8A,
       0xC1,
       0xCA,
       0x0C,
       0x47,
       0xEC,
       0x6C,
       0x69,
       0xAC,
       0x8E,
       0x13,
       0x66,
       0x77,
       0x0B,
       0x67,
       0x40,
       0xB4,
       0x8C,
       0xAB,
       0xB6,
       0xB7,
       0x2F,
       0x4E,
       0xAF,
       0x59,
       0x7A,
       0xB5,
       0x6F,
       0x77,
       0xD5,
       0xDC,
       0x93,
       0x4F,
       0xF0,
       0xF6,
       0xDA,
       0x8E,
       0x40,
       0x46,
       0x21,
       0x87,
       0x90,
       0x06,
       0xD7,
       0xF8,
       0xD6,
       0x52,
       0x38,
       0x9A,
       0xE5,
       0x94,
       0x0E,
       0x45,
       0x36,
       0x96,
       0x94,
       0x91,
       0xE8,
       0x4D,
       0x3C,
       0xF6,
       0x7D,
       0x86,
       0x53,
       0x3E,
       0x42,
       0x62,
       0x56,
       0x7F,
       0xA7,
       0x8B,
       0x83,
       0x09,
       0x28,
       0x41,
       0x4E,
       0x21,
       0x42,
       0xE9,
       0xC2,
       0x04,
       0xD9,
       0xD5,
       0x73,
       0xF4,
       0x19,
       0x0B,
       0x25,
       0xA2,
       0x6E,
       0x09,
       0xBB,
       0x3D,
       0xBC,
       0x25,
       0x36,
       0x90,
       0x0C,
       0x65,
       0xEF,
       0xFD,
       0xDB,
       0x05,
       0x5E,
       0xFF,
       0x4C,
       0x86,
       0xEA,
       0x12,
       0x61,
       0x23,
       0x5F,
       0x0B,
       0x89,
       0x64,
       0x5D,
       0x2B,
       0xD6,
       0xBE,
       0x0B,
       0x0A,
       0x3E,
       0xE5,
       0x5F,
       0x46,
       0xA1,
       0x0B,
       0xA2,
       0x82,
       0xA2,
       0x9A,
       0x12,
       0xDE,
       0xF3,
       0x70,
       0xA0,
       0xD8,
       0xA5,
       0xD6,
       0x72,
       0xC7,
       0x54,
       0x8A,
       0xEC,
       0xC9,
       0x44,
       0x35,
       0x9B,
       0x91,
       0xEC,
       0x6E,
       0x48,
       0x5B,
       0x39,
       0xAC,
       0x6A,
       0x72,
       0x3B,
       0xC7,
       0xD2,
       0x6C,
       0xBC,
       0xC8,
       0x6B,
       0x70,
       0x2C,
       0x20,
       0xAA,
       0x77,
       0x1C,
       0xF7,
       0xEA,
       0xCA,
       0xB9,
       0xC4,
       0x04,
       0x74,
       0x5F,
       0xA4,
       0xAF,
       0x4A,
       0x12,
       0x87,
       0x26,
       0x17,
       0x6E,
       0xB0,
       0x00,
       0x54,
       0xE3,
       0x84,
       0xA6,
       0xB0,
       0x44,
       0xBA,
       0x8F,
       0x15,
       0x96,
       0x1E,
       0xA1,
       0xCE,
       0x0B,
       0x28,
       0xCE,
       0x37,
       0xCA,
       0xEF,
       0x83,
       0xD6,
       0xAE,
       0x7D,
       0x8F,
       0x16,
       0x97,
       0x4D,
       0xF5,
       0x9B,
       0xEC,
       0x35,
       0x50,
       0x90,
       0xCB,
       0x5E,
       0xDF,
       0x13,
       0x3C,
       0xDF,
       0x8C,
       0x51,
       0x20,
       0x64,
       0xD7,
       0x7D,
       0xAF,
       0x7A,
       0xEE,
       0x06,
       0x90,
       0xBE,
       0x53,
       0xCA,
       0xF7,
       0xDB,
       0x23,
       0x09,
       0xAB,
       0x17,
       0x49,
       0x0F,
       0xA0,
       0xCD,
       0xDC,
       0xFE,
       0x98,
       0x3C,
       0x0F,
       0x43,
       0x8A,
       0x58,
       0x07,
       0x2A,
       0xE8,
       0xB3,
       0x99,
       0xD8,
       0x04,
       0x1A,
       0x99,
       0xAC,
       0xBC,
       0x7A,
       0xE2,
       0xED,
       0xC4,
       0x9D,
       0xC0,
       0xC0,
       0x01,
       0x1D,
       0xCA,
       0x66,
       0x7F,
       0xE8,
       0xC6,
       0x1C,
       0xF0,
       0x78,
       0x59,
       0xF7,
       0x61,
       0x31,
       0xEB,
       0xDF,
       0xEB,
       0xDE,
       0x41,
       0xC5,
       0x23,
       0x4A,
       0xA5,
       0x08,
       0xEA,
       0xBD,
       0x29,
       0x1F,
       0xFB,
       0x4A,
       0xED,
       0xFE,
       0x3D,
       0x09,
       0xAA,
       0xF1,
       0x07,
       0x07,
       0xB3,
       0xA4,
       0x28,
       0x1C,
       0x03,
       0xCD,
       0x1E,
       0xC1,
       0x50,
       0x03,
       0xFE,
       0xD0,
       0xCB,
       0x87,
       0x88,
       0x45,
       0x70,
       0x00,
       0x77,
       0x9F,
       0xAB,
       0xCA,
       0x8C,
       0x4D,
       0x5F,
       0x28,
       0xF6,
       0xEF,
       0x1C,
       0x9C,
       0xA1,
       0xA1,
       0xAD,
       0x60,
       0x0C,
       0x77,
       0x9A,
       0x92,
       0x92,
       0x36,
       0x5A,
       0x19,
       0xD0,
       0x96,
       0x59,
       0x2E,
       0x62,
       0x0C,
       0xF4,
       0xA2,
       0x5C,
       0x0A,
       0xB7,
       0x9F,
       0x7B,
       0x10,
       0xBE,
       0xFB,
       0x1C,
       0x8B,
       0x99,
       0x8E,
       0xC3,
       0x8E,

   };

   uint8_t Private_Key_Test3[32] = {
       0x81, 0x51, 0x5E, 0xDB, 0xF5, 0xD2, 0x78, 0x3B, 0xDD, 0x81, 0xB6, 0x84, 0xBB, 0xE2, 0xFF, 0x02,
       0x7A, 0x5C, 0xBA, 0xE7, 0x37, 0x0C, 0x52, 0xCC, 0x65, 0xE5, 0x30, 0x33, 0xE8, 0x5E, 0x83, 0x7B};
   uint8_t Publickey_Test3[64] =  {
    0xBA, 0x0B, 0xE4, 0x8F, 0xE5, 0x97, 0xAA, 0xD9, 0x0B, 0xB1, 0x41, 0x25, 0x80, 0x9F, 0xA5, 0x62, 
    0xA9, 0xFE, 0x51, 0x05, 0xED, 0x58, 0x56, 0x24, 0xF5, 0xEB, 0xEB, 0xD0, 0xCF, 0x68, 0xF7, 0xFA, 
    0x01, 0x21, 0xFD, 0xD4, 0xEC, 0x2C, 0xA3, 0x05, 0x1D, 0xB4, 0x66, 0x85, 0xE9, 0x73, 0x06, 0x8F, 
    0x72, 0xA5, 0x7C, 0xD2, 0xED, 0x15, 0xBD, 0x67, 0x0F, 0x43, 0x7C, 0xC8, 0xCA, 0xB4, 0x8C, 0x8C
};
   result = peace_sm2_sign(buf_3, sizeof(buf_3), Private_Key_Test3, Publickey_Test3, &Sig_Result[0], Sig_R, Sig_S, &siglen);
   for (int i = 0; i < siglen; i++)
   {
      printf("%02x ", Sig_Result[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_R[i]);
   }
   printf("\n");
   for (int i = 0; i < 32; i++)
   {
      printf("%02x ", Sig_S[i]);
   }
   CU_ASSERT_EQUAL(result, E_OK);
   result = peace_sm2_verify(buf_3, sizeof(buf_3), Private_Key_Test3, Publickey_Test3, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_OK);
   Sig_Result[2] += 1;
   Sig_Result[5] += 1;
   result = peace_sm2_verify(buf_3, sizeof(buf_3), Private_Key_Test3, Publickey_Test3, &Sig_Result[0], siglen);
   CU_ASSERT_EQUAL(result, E_NOT_OK);
   peace_sm2_KEY key;
   uint8_t encrypt_result[1024];
   uint8_t decrypt_result[1024];
   size_t encrypt_outlen;
   size_t decrypt_outlen;

   for (uint8_t i = 0; i < 32; i++)
   {

      key.public_key.x[i] = Publickey_Test1[i];
      key.public_key.y[i] = Publickey_Test1[i + 32];
      key.private_key[i] = Private_Key_Test1[i];
   }
   /*len<256*/
   // result = peace_sm2_encrypt(&key, buf_1, sizeof(buf_1), encrypt_result, &encrypt_outlen);
   //  CU_ASSERT_EQUAL(result, E_OK);
   //  result = peace_sm2_decrypt(&key, encrypt_result, encrypt_outlen, decrypt_result, &decrypt_outlen);
   //  CU_ASSERT_EQUAL(result, E_OK);
}

/* The main() function for setting up and running the tests.
 * Returns a CUE_SUCCESS on successful running, another
 * CUnit error code on failure.
 */
int main()
{
   CU_pSuite pSuite = NULL;

   /* initialize the CUnit test registry */
   if (CUE_SUCCESS != CU_initialize_registry())
      return CU_get_error();

   /* add a suite to the registry */
   pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
   if (NULL == pSuite)
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* add the tests to the suite */
   /* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
   if (NULL == CU_add_test(pSuite, "test of sm2()", test_sm2))
   {
      CU_cleanup_registry();
      return CU_get_error();
   }

   /* Run all tests using the console interface */
   CU_basic_set_mode(CU_BRM_VERBOSE);
   CU_basic_run_tests();
   CU_cleanup_registry();
   return CU_get_error();
}
